Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS: review of all include and require statements #362

Merged
merged 1 commit into from
Oct 5, 2019

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 19, 2019

[This PR is part of a series to introduce code style checking to the repo]

include and require are language constructs, not functions.

With that in mind there are a number of best practices surrounding them:

  • There is no need to use parenthesis and not doing so will be, albeit marginally, faster.
  • Always pass an absolute path for maximum portability.
    Using dirname(__FILE__) instead of __DIR__ to maintain compatibility with PHP 5.2.
  • Use require_once instead of include when the file is required for the rest of the script to be able to function.

`include` and `require` are language constructs, not functions.

With that in mind there are a number of best practices surrounding them:
* There is no need to use parenthesis and not doing so will be, albeit marginally, faster.
* Always pass an absolute path for maximum portability.
    Using `dirname(__FILE__)` instead of `__DIR__` to maintain compatibility with PHP 5.2.
* Use `require_once` instead of `include` when the file is _required_ for the rest of the script to be able to function.
@jrfnl jrfnl added this to the 1.7.1 milestone Sep 19, 2019
@ntwb ntwb merged commit 56286a0 into master Oct 5, 2019
@ntwb ntwb deleted the feature/cs-include-require-review branch October 5, 2019 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants